<template>
  <ExperimentTemplateRecordEdit
    v-model="formData"
    :operate-type="2"
    :dialog-form-visible.sync="dialogFormVisible"
  />
</template>
<script>
import { getSingleList } from "../AuditComponents/api/ExperimentTemplateRecord.js";
import ExperimentTemplateRecordEdit from "@/ModuleEln/ModuleEln/views/ModuleEln/ExperimentTemplateRecord/ExperimentTemplateRecordEdit.vue";

export default {
  name: "AuditExperimentTemplateEdit",
  components: { ExperimentTemplateRecordEdit },
  props: {
    value: {
      type: Boolean,
      default: false,
    },
    editId: {
      type: [String, Number],
      default: "",
    },
    row: {
      type: Object,
      default: () => {},
    },
  },
  data() {
    return {
      dialogFormVisible: false,
      formData: null,
    };
  },
  watch: {
    dialogFormVisible: {
      handler(newVal) {
        !newVal && this.$emit("update:dialogFormVisible", false);
      },
      immediate: false,
    },
  },
  mounted() {
    this.getDataInfo();
  },
  methods: {
    getDataInfo() {
      return new Promise((resolve, reject) => {
        getSingleList({ id: this.editId })
          .then((res) => {
            this.formData = res.data;
            this.dialogFormVisible = true;
            resolve();
          })
          .catch(() => {
            reject();
          });
      });
    },
  },
};
</script>
